const path = require('path')
const compose = require('koa-compose')
const cors = require('@koa/cors')
const koaBody = require('koa-body')
const static = require('koa-static')

const logger = require('./logger')
const send = require('./send')
const router = require('../router/index.js')

module.exports = compose([
	logger,
	send,
	koaBody({
		multipart: true,
		formidable: {
			multiples: false,
			maxFileSize: 20 * 1024 * 1024
		}
	}),
	cors(),
	router,
	static(path.join(__dirname, '../view')),
])
